<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>财务管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="../../common/bootstrap/css/bootstrap.css" media="all">
    <link rel="stylesheet" type="text/css" href="../../common/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="../../common/global.css" media="all">
    <link rel="stylesheet" type="text/css" href="../../css/customer_list.css" media="all">
</head>
<style>
    #roleAuthTable + .layui-table-view .layui-table tbody tr:hover {
        background-color: transparent;
    }
    tbody tr .layui-table-cell {
        height: auto !important;
    }
    .layui-input-block {
        margin-left: 85px;
        min-height: 36px;
    }
    tbody tr td:last-child .layui-table-cell{
        white-space: normal !important; /* 允许多行显示 */
        word-break: break-all;          /* 长单词或 URL 地址换行 */
    }
    .must{
        color: red;
    }
</style>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-form toolbar layui-form-pane">
                <form lay-filter="searchStationForm" id="searchStationForm" class="layui-form model-form">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">询价来源</label>
                        <div class="layui-input-inline">
                            <input name="bus_from_company_name" id="bus_from_company_name" class="layui-input" type="text" placeholder="" autocomplete="off"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">配件商</label>
                        <div class="layui-input-inline">
                            <input name="bus_to_company_name" id="bus_to_company_name" class="layui-input" type="text" placeholder="" autocomplete="off"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">车辆品牌</label>
                        <div class="layui-input-inline">
                            <input name="brand_name" id="brand_name" class="layui-input" type="text" placeholder="" autocomplete="off"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">车型</label>
                        <div class="layui-input-inline">
                            <input name="car_model" id="car_model" class="layui-input" type="text" placeholder="" autocomplete="off"/>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">车牌号</label>
                        <div class="layui-input-inline">
                            <input name="vehicle_license_num" class="layui-input" type="text" placeholder="" autocomplete="off"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">询价人</label>
                        <div class="layui-input-inline">
                            <input name="loss_assessor" class="layui-input" type="text" placeholder="" autocomplete="off"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">修理厂</label>
                        <div class="layui-input-inline">
                            <input name="repair_company" class="layui-input" type="text" placeholder="" autocomplete="off"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">下单时间</label>
                        <div class="layui-input-inline">
                            <input type="text" name="due_date" placeholder="时间段" class="layui-input" id='due_date'>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label w-auto">业务员</label>
                            <div class="layui-input-inline">
                                <input name="add_user_name" class="layui-input" type="text" placeholder="" autocomplete="off"/>
                            </div>
                        </div>
                    <div class="layui-inline">
                        <button id="btnSearch" class="layui-btn icon-btn"><i class="layui-icon">&#xe615;</i>搜索
                        </button>
                        <button id="btnReset" class="layui-btn layui-btn-warm"><i class="layui-icon">&#xe669;</i>重置
                        </button>
                        <button id="btnExport" class="layui-btn layui-btn-warm"><i class="layui-icon">&#xe67d;</i>导出
                        </button>
                    </div>
                </div>
                </form>
            </div>
            <table class="layui-table" id="infoTable" lay-filter="infoTable"></table>
        </div>
    </div>
</div>
<script type="text/javascript" src="../../js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="../../js/jquery.cookie.js"></script>
<script type="text/javascript" src="../../common/layui/layui2.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script type="text/javascript" src="../../js/main.js"></script>
<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table','admin', 'laydate','upload'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var admin = layui.admin;
        var laydate = layui.laydate;
        var user_info =  JSON.parse(getSessionStorage('uanme'));
        laydate.render({
            elem: '#due_date'
            ,range: true
            ,trigger: 'click'
        });

        form.render();
        //渲染表格
        table.render({
            elem: '#infoTable',
            url: access_baseurl+'Order/getList',
            where: {
                opt_role_id:user_info.role_id,
                opt_user_id:user_info.user_id
            },
            page: true,
            cellMinWidth: 100,
            cols: [
                [
                    {align: 'center',field: 'sure_datetime',rowspan:4, title: '下单时间',width:180,fixed:'left'},
                    {align: 'center',field: 'business_entity',rowspan:4, title: '经营主体',templet:function (d) {
                            if(d.business_entity === 'ht'){
                                return '鸿天';
                            }else if(d.business_entity === 'cy'){
                                return '车友';
                            }else if(d.business_entity === 'personal'){
                                return '个体户';
                            }else {
                                return '';
                            }
                        }
                    },
                    {align: 'center',field: 'add_user_name',rowspan:4, title: '业务员'},
                    {align: 'center',field: 'bus_from_company_name',rowspan:4,  title: '询价来源',width:200},
                    // {align: 'center',field: 'city',rowspan:4,  title: '地区'},
                    {align: 'center',field: 'vehicle_license_num',rowspan:4,  title: '车牌号'},
                    {align: 'center',field: 'brand_name',rowspan:4,  title: '车辆品牌'},
                    {align: 'center',field: 'car_model',rowspan:4,  title: '车型名称'},
                    {align: 'center',field: 'bus_user_name',rowspan:4,  title: '询价人'},
                    {align: 'center',field: 'bus_user_phone', rowspan:4, title: '询价人电话',width:130},
                    {align: 'center',field: 'repair_company_name',rowspan:4,  title: '修理厂名称',width:200},
                    {align: 'center',field: 'repair_company_phone',rowspan:4,  title: '修理厂电话',width:130},
                    {align: 'center',field: 'bus_to_company_name',rowspan:4,  title: '供货商名称',width:150},
                    {align: 'center', colspan:13,title: '销售成本'},
                    {align: 'center', colspan:6,title: '销售收入'},
                    {align: 'center', colspan:3,title: '销售毛利'},
                    {align: 'center', colspan:2,title: '发票信息'},
                    {align: 'center',rowspan:4, title: '有退货',templet:function (d) {
                            if(d.have_returns === 1){
                                return '有';
                            }else {
                                return '无';
                            }
                        }
                    },
                ],
                [
                    {align: 'center',field: 'totall_price',rowspan:3, title: '采购金额'},
                    {align: 'center',field: 'freight',rowspan:3, title: '运费+木架'},
                    {align: 'center',field: 'tax',rowspan:3, title: '税点'},
                    {align: 'center',field: 'totall_price_tax',rowspan:3, title: '含税采购金额',width:150},
                    {align: 'center',colspan:6, title: '商务费'},
                    {align: 'center',field: 'total_cost',rowspan:3, title: '总成本'},
                    {align: 'center',rowspan:3,field: 'returned_money_info', title: '是否付款'},
                    {align: 'center',field: 'returned_money_datetime',rowspan:3, title: '付款时间',width:180},
                    {align: 'center',field: 'sales_totall_price_tax',rowspan:3, title: '销售金额'},
                    {align: 'center',field: 'sales_returned_money',rowspan:3, title: '回款金额'},
                    {align: 'center',field: 'sales_returned_money_datetime',rowspan:3, title: '回款时间',width:180},
                    {align: 'center',field: 'sales_returned_diff',rowspan:3, title: '回款差额'},
                    {align: 'center',field: 'sales_returned_money_type',rowspan:3, title: '回款账户'},
                    {align: 'center',field: 'sales_returned_money_state',rowspan:3, title: '是否结清',templet:function (d) {
                        if(d.sales_returned_money_state === 2){
                            return '是';
                        }else{
                            return '否'
                        }
                    }},
                    {align: 'center',field: 'profit',rowspan:3, title: '毛利'},
                    {align: 'center',field: 'profit_rate',rowspan:3, title: '实际毛利率'},
                    {align: 'center',field: 'plan_profit_rate',rowspan:3, title: '参考毛利率'},
                    {align: 'center',rowspan:3, title: '进项票',width:150,
                        templet:function (d) {
                            if(d.invoice_state === 2){
                                return d.invoice_datetime+'已开';
                            }else{
                                return '未开'
                            }
                        }
                    },
                    {align: 'center',rowspan:3, title: '销项票',width:150,
                        templet:function (d) {
                            if(d.sales_invoice_state === 2){
                                return d.sales_invoice_datetime+'已开';
                            }else{
                                return '未开'
                            }
                        }
                    },
                ],
                [
                    {align: 'center',colspan:3, title: '询价人'},
                    {align: 'center',colspan:3, title: '修理厂'},
                ],
                [
                    {align: 'center',field: 'loss_assessor_money', title: '询价人'},
                    {align: 'center',field: 'loss_assessor_type', title: '付款方式'},
                    {align: 'center',field: 'loss_assessor_datetime', title: '付款时间',width:180},
                    {align: 'center',field: 'repair_company_money', title: '修理厂'},
                    {align: 'center',field: 'repair_company_type', title: '付款方式'},
                    {align: 'center',field: 'repair_company_datetime', title: '付款时间',width:180}
                ]
            ]
        });

        // 搜索按钮点击事件
        $('#btnSearch').click(function () {
            var where = getWhere();
            table.reload('infoTable', {where: where});
            return false;

        });
        $('#btnReset').click(function () {
            var t = $('#searchStationForm [name]').serializeArray();
            var data={};
            $.each(t, function() {
                data[this.name] = '';
            });
            form.val('searchStationForm',data);
            form.render();
            table.reload('infoTable', {where: data});
            return false;
        });

        $('#btnExport').click(function () {
            var where = getWhere();
            location.href = access_baseurl + 'Order/orderExport.html?bus_from_company_name='+where.bus_from_company_name+'&bus_to_company_name='
                +where.bus_to_company_name+'&car_model='+where.car_model+'&vehicle_license_num='+where.bus_to_company_name+'&bus_to_company_name='
                +where.vehicle_license_num+'&loss_assessor='+where.loss_assessor+'&repair_company='+where.repair_company+'&due_date='
                +where.due_date+'&role_id='+user_info.role_id+'&opt_user_id='+user_info.user_id;
            return false;
        });
        function getWhere() {
            var t = $('#searchStationForm [name]').serializeArray();
            var where = {};
            $.each(t, function() {
                where[this.name] = this.value;
            });
            return where;
        }
    });
</script>
</body>
</html>